package com.plpm.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 应用初始化器
 * 
 * @author PLPM Team
 * @version 1.0
 */
@Slf4j
@Component
public class ApplicationInitializer implements ApplicationRunner {

    @Autowired
    private IoTDBService iotdbService;

    @Autowired
    private FileUploadService fileUploadService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("Starting Into_IoTDB application initialization...");
        
        try {

            // 初始化文件上传目录
            fileUploadService.initializeDirectories();
            log.info("File upload directories initialized successfully");
            
            log.info("Into_IoTDB application initialization completed successfully");
            
        } catch (Exception e) {
            log.error("Failed to initialize application", e);
            throw e;
        }
    }
}
